<template>
  <div id="app">
      <router-view />
      <van-tabbar v-model="active" route>
        <template v-if="login" >
          <van-tabbar-item name="" replace to="/writer" icon="home-o">写留言</van-tabbar-item>
          <van-tabbar-item name="注册" replace to="/search" icon="search">查看留言</van-tabbar-item>
          <van-tabbar-item name="注册" replace to="/info" icon="search">个人中心</van-tabbar-item>
        </template>
        <template v-if="login === null || login === false">
          <van-tabbar-item name="" replace to="/" icon="home-o">登录</van-tabbar-item>
          <van-tabbar-item name="注册" replace to="/register" icon="search">注册</van-tabbar-item>
        </template>
      </van-tabbar>
  </div>
</template>
<script>
import Login from './views/Login'
import Register from "./views/Regist";
import {Bus} from './bus.js'
export default {
  components:{
    Register,
    Login
  },
  data(){
    return {
      active: "登录",
      login: this.$store.getters.getLogin,
    }

  },
  computed:{
  },
  methods: {
  },
  created() {
    console.log('app login statue',this.$store.getters.getLogin)
    Bus.$on('change-nav',(val)=>{
      this.login = val
    })
  },
  mounted() {
    console.log('渲染成功')
    console.log('app login statue',this.$store.getters.getLogin)
  },
  watch: {
    "$store.state.login":{
      handler:function(newVal,oldVal){
        console.log('新值：'+newVal,"旧值"+oldVal);
      }
    }
  }


}
</script>

<style lang="less">
#app {
}


</style>
